package com.sky.mapper.common;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.dto.DishDTO;
import com.sky.dto.DishPageQueryDTO;
import com.sky.enumeration.OperationType;
import com.sky.pojo.Category;
import com.sky.pojo.Dish;
import com.sky.pojo.DishFlavor;
import com.sky.vo.DishVO;
import com.sky.vo.SetmealVO;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface DishMapper {

    // 根据分类id查询菜品数量
    @Select("select count(id) from dish where category_id = #{categoryId}")
    Integer countByCategoryId(Long categoryId);
    /**
     * 新增菜品数据
     */
    @AutoFill(value = OperationType.INSERT)
    void insert(Dish dish);

    // 菜品分页查询
    Page<DishVO> pageQuery(DishPageQueryDTO dishPageQueryDTO);

    //根据id删除菜品
    @Delete("delete from dish where id = #{id}")
    void deleteById(Long id);
    // 批量删除菜品
    void delete(List<Long> ids);

    /**
     * 修改菜品数据
     */
    @Insert("update dish set status = #{status} where id = #{id}")
    void startOrStop(@Param("status") Integer status,@Param("id") Integer id);
    /**
     * 修改菜品数据
     */
    @AutoFill(value = OperationType.UPDATE)
    void updateWithFlavor(DishDTO dishDTO);
    //根据菜品id和状态查找菜品数量
    Integer selectCountByIdsAndStatus(@Param("ids") List<Long> ids, @Param("status") Integer status);

    //根据分类id查询菜品
    @Select("select * from dish where category_id = #{categoryId}")
    List<DishVO> findDishByCategoryId(Long categoryId);


    // 根据id查询菜品
    @Select("select * from dish where id = #{id}")
    DishVO findDishById(Long id);


    //根据分类id查询菜品user
    @Select("select * from dish where category_id = #{categoryId}")
    List<DishVO> findDishByCategory(Long categoryId);

    //根据菜品id查询菜品口味
    @Select("select * from dish_flavor where dish_id = #{id}")
    List<DishFlavor> findFlavorByDishId(Long id);

    @Select("select * from dish where id = #{id}")
    List<DishVO> SelectDishById(Long id);
}
